<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ page isELIgnored="false"%>
<jsp:include page="../frame/header.jsp"></jsp:include>

<title>评论列表</title>

<style>
.pagination .active a {
	/*background-color: #CC0041;
	color:white;*/
}
</style>

</head>

<body>

	<div class="container-fluid">
		<div id="market" class="row-fluid">
			<div>
				<ul class="breadcrumb">
					<li><a href="#">系统管理</a> <span class="divider">/</span></li>
					<li><a href="#">系统评论列表</a></li>
				</ul>
			</div>

			<div class="box">
				<div class="box-header well" data-original-title>
					<h2>
						<i class="icon-th"></i> 评论列表
					</h2>

					<div class="box-icon">
						<a href="#" class="btn btn-setting btn-round"><i
							class="icon-cog"></i></a> <a href="#"
							class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
						<a href="#" class="btn btn-close btn-round"><i
							class="icon-remove"></i></a>
					</div>
				</div>
				<div class="box-content">
					<div id="search-form">
						<form id="searchForm" method="post" class="form-search span12" action="<c:url value="/admin/comment/search"/>">
							<div class="in-line">
								<label>所属模块：</label>
								<select data-placeholder="全部" id="moduleType" name="moduleType" data-rel="chosen">
									<option value="1" <c:if test="${searchForm.moduleType == 1 }">selected</c:if>>商户</option>
									<option value="2" <c:if test="${searchForm.moduleType == 2 }">selected</c:if>>攻略</option>
									<option value="3" <c:if test="${searchForm.moduleType == 3 }">selected</c:if>>二手交易</option>
									<option value="4" <c:if test="${searchForm.moduleType == 4 }">selected</c:if>>房屋租赁</option>
									<option value="5" <c:if test="${searchForm.moduleType == 5 }">selected</c:if>>票务</option>
									<option value="6" <c:if test="${searchForm.moduleType == 6 }">selected</c:if>>优惠券</option>
									<option value="7" <c:if test="${searchForm.moduleType == 7 }">selected</c:if>>订餐</option>
								</select>
								<input type="hidden" name="pageNum" id="pageNum" value="${searchForm.pageNum }">
								<label>信息标题：</label>
								<input type="text" name="title" id="title" value="${searchForm.title }" 
										class="input-large search-query">
								<label>用户名：</label>
								<input type="text" name="username" id="username" value="${searchForm.username }" 
										class="input-large search-query">
										
								<button type="button" id="searchBtn" class="btn">&nbsp;&nbsp;搜索&nbsp;&nbsp;</button>
							</div>
							
							<input type="hidden" name="commentId" id="commentId" value="0">
							
							
						</form>

					</div>
					<table id="userInfo" class="table table-striped table-bordered ">
						<thead>
							<tr>
								<th width="30">序号</th>
								<th >信息标题</th>
								<th >评论内容</th>
								<th >星星数</th>
								<th >用户名</th>
								<th >评论时间</th>
								<th width="80">操作</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach var="comment" items="${pageModel.result }" varStatus="status">
								<tr>
									<td>${status.index+1 }</td>
									<td>${comment.title }</td>
									<td>${fn:replace(comment.commentContent, 'resources/','../../resources/')} </td>
									<td>${comment.stars } </td>
									<td>${comment.username }</td>
									<td>${comment.commentTime }</td>
									<td>&nbsp;&nbsp; <a
										href="javascript:del('${comment.commentId }')">删除</a></td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
					
					<div id="mypager" class="mypager"></div>
				</div>
			</div>
		</div>
		<!--/fluid-row-->

	</div>
	<!--/.fluid-container-->

	<jsp:include page="../frame/scripts.jsp"></jsp:include>
	<script type="text/javascript">
	
	var pageNum = "${pageModel.pageNum}";
	var totalPage = "${pageModel.totalPage}";
	var numPerPage = "${pageModel.numPerPage}";
	
	$(document).ready(function(){
		
		$('#mypager').bootstrapPaginator({
			currentPage:pageNum,
			totalPages:totalPage,
			numberOfPages:numPerPage,
			onPageClicked:function(event, originalEvent, type,page){
				$("input[name='pageNum']").val(page);
				$("#searchForm").submit();
			}
		});
		
		$("#moduleType").change(function(){
			$("#searchForm").submit();
		});
		
		$('#searchBtn').click(function(){
			$("#searchForm").submit();
		})
	})
	
	function del(commentId){
		if(confirm("确定要删除吗？")){
			$("input[name='commentId']").val(commentId);
			$("#searchForm").submit();
		}
	}
	</script>
</body>
</html>
